from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys

# 后面是你的浏览器驱动位置，记得前面加r'','r'是防止字符转义的
driver = webdriver.Chrome(r'C:\Users\Administrator\AppData\Local\Programs\Python\Python38\chromedriver.exe')
driver.maximize_window()
# 用get打开百度页面
driver.get("http://www.yujianlong.com")
sleep(2)
# 查找页面的“设置”选项，并进行点击
# driver.find_elements_by_link_text('设置')[0].click()
# sleep(2)
# # 打开设置后找到“搜索设置”选项，设置为每页显示50条
# driver.find_elements_by_link_text('搜索设置')[0].click()
# sleep(2)
try:
 
    line_list = driver.find_elements_by_xpath("//article[contains(@class,'article-list-1')]")
    print(123);
    #'''xpath提取特征'''
    for line in line_list:
        # t = line.find_element_by_xpath("//header/h1/a")
        print ('%s - %s' % (line.text, type(line.text)))
       
    driver.quit()
    # print ('test pass: element found by link text')
    
except Exception as e:
    print ("YuTest", format(e))


# 关闭浏览器
# driver.quit()